<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>完美电商</title>

    <!-- Bootstrap -->
    <link href="${pageContext.request.contextPath}/static/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="${pageContext.request.contextPath}/static/vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="${pageContext.request.contextPath}/static/vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- Animate.css -->
    <link href="${pageContext.request.contextPath}/static/vendors/animate.css/animate.min.css" rel="stylesheet">
    <%--iCheck--%>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/vendors/iCheck/skins/flat/green.css">

    <!-- Custom Theme Style -->
    <link href="${pageContext.request.contextPath}/static/build/css/custom.min.css" rel="stylesheet">
    <style type="text/css">
        .login{
            width: 100%;
            height: 100%;
            background: url("${pageContext.request.contextPath}/static/images/bg.jpg") no-repeat;
            background-size: cover;
        }
    </style>
</head>

<body class="login">
<div>
    <a class="hiddenanchor" id="signup"></a>
    <a class="hiddenanchor" id="signin"></a>

    <div class="login_wrapper">
        <div class="animate form login_form">
            <section class="login_content" style="background: #FFFFFF;width: 450px;padding: 30px 30px;box-shadow: 1px 1px 1px #f7f7f7f7">
                <form class="form-horizontal form-label-left" id="form_login" method="post">
                    <h1>完美电商登录</h1>
                    <div class="col-md-12 col-sm-12 col-xs-12 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" name="username" id="username" placeholder="用户名">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <div class="col-md-12 col-sm-12 col-xs-12 form-group has-feedback">
                        <input type="password" class="form-control has-feedback-left" name="password" id="password" placeholder="密码">
                        <span class="fa fa-lock form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <div class="col-md-12 col-sm-12 col-xs-12 form-group has-feedback">
                        <div class="pull-left">
                            <input type="checkbox" name="checkBoxName" class="flat pull-left" > 记住我
                        </div>
                        <div class="pull-right">
                            <a href="${pageContext.request.contextPath}/user/info/forget">忘记密码？</a>
                        </div>
                    </div>

                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <input type="button" id="loginBtn" class="btn btn-success submit" value="立即登录"/>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="separator">
                        <div class="clearfix"></div>
                        <div>
                            <p>©2018~2019 All Rights Reserved. 软件工程实训小组</p>
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
<%--脚本--%>

<!-- jQuery -->
<script src="${pageContext.request.contextPath }/static/vendors/jquery/dist/jquery.min.js"></script>

<!-- Bootstrap -->
<script src="${pageContext.request.contextPath }/static/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<%--iCheck--%>
<script src="${pageContext.request.contextPath}/static/vendors/iCheck/icheck.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="${pageContext.request.contextPath }/static/build/js/custom.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#loginBtn").click(function () {
            var username= $("#username").val();
            username = $.trim(username);
            if (username==null||username==""){
                alert("请输入用户名!");
                return false;
            }
            $.ajax({
                data:$("#form_login").serialize(),
                url:"${pageContext.request.contextPath}/user/info/login.json",
                dataType:"json",
                contentType:"application/json",
                success:function (data) {
                    if (data.code==1){
                        window.location.href="/user/success.do";
                    }else  if (data.code==3){
                        alert("只有超管和管理员才能进入！");
                    }
                    else {
                        alert(data.msg);
                    }
                },
                error:function () {
                    alert("未知错误！");
                }
            });
        });
    });
</script>
</body>
</html>
